﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Portal.Xml.Utility;

namespace Portal.Systems.Model
{
    public class RoleMenuCls
    {
        public string RoleMenuId;
        public string frkRoleId;
        public string WebFolderId;
        public int Allow;
        public string AssetCode;
    }

    public class RoleMenuParser
    {
        public static RoleMenuCls CreateInstance()
        {
            //tao 1 class trang....
            RoleMenuCls oRoleMenuCls = new RoleMenuCls();
            return oRoleMenuCls;
        }

        public static RoleMenuCls ParseFromXml(string XmlData)
        {
            DataSet ds = XmlUtility.GetDataSetFromXml(XmlData);
            RoleMenuCls oRoleMenuCls = ParseFromDataRow(ds.Tables[0].Rows[0]);
            return oRoleMenuCls;
        }


        public static RoleMenuCls ParseFromDataRow(DataRow dr)
        {
            RoleMenuCls ORoleMenuCls = new RoleMenuCls();
            ORoleMenuCls.RoleMenuId = (string)dr["RoleMenuId"];
            ORoleMenuCls.frkRoleId = (string)dr["frkRoleId"];
            ORoleMenuCls.WebFolderId = (string)dr["WebFolderId"];
            ORoleMenuCls.Allow = int.Parse(dr["Allow"].ToString());
            ORoleMenuCls.AssetCode = (string)dr["AssetCode"];
            return ORoleMenuCls;
        }

        public static RoleMenuCls[] ParseFromDataTable(DataTable dtTable)
        {
            RoleMenuCls[] RoleMenus = new RoleMenuCls[dtTable.Rows.Count];
            for (int iIndex = 0; iIndex < dtTable.Rows.Count; iIndex++)
            {
                RoleMenus[iIndex] = ParseFromDataRow(dtTable.Rows[iIndex]);
            }

            return RoleMenus;
        }
    }
}


